package cn.yunhe.service.impl;

import cn.yunhe.dao.EmployeeMapper;
import cn.yunhe.model.Employee;
import cn.yunhe.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/7/22.
 */
@Service("employeeService")
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;

    public Employee findEmployee(int id) {
        Map<String,Object> employee = employeeMapper.findEmployee(id);
        Employee e = new Employee();
        e.setUsername((String) employee.get("username"));
        e.setPassword((String) employee.get("password"));
        e.setBirthday((Date) employee.get("birthday"));
        e.setEntry_date((Date) employee.get("entry_date"));
        e.setJob((String) employee.get("job"));
        e.setResume((String) employee.get("resume"));
        return e;
    }

    public Employee searchEmployee(Employee employee) {
        Employee e = employeeMapper.searchEmployee(employee);
        return e;
    }

    public List<Employee> searchAll() {
        return employeeMapper.searchAll();
    }

    public void deleteEmployee(int id) {
        employeeMapper.deleteEmployee(id);
    }

    public void updateEmployee(Employee employee) {
        employeeMapper.updateEmployee(employee);
    }


    public EmployeeMapper getEmployeeMapper() {
        return employeeMapper;
    }

    public void setEmployeeMapper(EmployeeMapper employeeMapper) {
        this.employeeMapper = employeeMapper;
    }
}
